﻿using System;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Web;

namespace BGCMS.Models
{
    /// <summary>
    /// Class used to send emails
    /// </summary>
    public class Email
    {
        /// <summary>
        /// Static function that takes care of sending an email message
        /// </summary>
        /// <param name="recipient">The email address of the recipient</param>
        /// <param name="subject">The subject of the email message</param>
        /// <param name="body">The body of the email message</param>
        public static void SendEmail(string recipient, string subject, string body)
        {
            using (MailMessage message = new MailMessage())
            {
                message.BodyEncoding = System.Text.Encoding.UTF8;

                message.To.Add(recipient);

                message.Subject = subject;
                message.Body = body;
                message.IsBodyHtml = true;
                SmtpClient client = new SmtpClient();
                client.EnableSsl = true;
                client.Send(message);
            }
        }
    }
}